package com.jinbiao.annotion1;

import java.lang.reflect.Method;

public class Test_NoBug {

	public static void main(String[] args) {
		NoBug bug = new NoBug();

		// 反射获取方法
		Method[] methods = bug.getClass().getDeclaredMethods();

		StringBuilder log = new StringBuilder();
		int errornum = 0;

		for (Method method : methods) {
			if (method.isAnnotationPresent(Check.class)) {

				
				try {
					method.setAccessible(true);
					method.invoke(bug, null);
				} catch (Exception e) {

					errornum++;
					log.append(method.getName());
					log.append("");
					log.append("has eror:");
					log.append("\n\r" + "caused by");
					log.append(e.getCause().getClass().getName());
					log.append("\r\n");
					log.append(e.getCause().getMessage());
				}
			}
		}
		
		log.append(bug.getClass().getSimpleName());
		log.append("has");
		log.append(errornum);
		log.append("error");
		System.out.println(log.toString());
	}
}
